'use strict';
// Copyright 2014 Blueant Inc. All Rights Reserved.

/**
 * @fileoverview 开服活动
 * @author sundbcn@gmail.com (sun debing)
 */

var dataApi = require('../libs/dataApi');
var _ = require('lodash');

/**
 * 获取开服狂欢奖励
 * @param  {[type]} vip [description]
 * @return {[type]}     [description]
 */
exports.getOpenServiceRewardList = function (job_type, receive_day) {
    return _.filter(dataApi.open_service.findById(receive_day), {
        job_type: job_type
    });
};

/**
 * 获取成长赠礼
 * @param  {[type]} vip [description]
 * @return {[type]}     [description]
 */
exports.getGrowUpRewardList = function (job_type, lv) {
    return _.filter(dataApi.grow_up.findById(lv), {
        job_type: job_type
    });
};

/**
 * 获取成长赠礼等级列表
 * @return {[type]}     [description]
 */
exports.getGrowUpLvlList = function () {
    var lvl_list = [];

    dataApi.grow_up.each(function (grow_up_item, key) {
        lvl_list.push(parseInt(key));
    });
    return lvl_list;
};

/**
 * 获取主城等级奖励信息列表
 * @param  {lv}         [主城等级]
 * @return {[reward_info]}     [奖励信息]
 */
exports.getMainCityLevelRewardList = function (job_type, lv) {
    return _.filter(dataApi.castle_lvl.findById(lv), {
        job_type: job_type
    });
};

/**
 * 获取城堡等级列表
 * @return {[type]}     [description]
 */
exports.getMainCityLevelList = function () {
    var lvl_list = [];
    dataApi.castle_lvl.each(function (sprint_lvl_item, key) {
        lvl_list.push(parseInt(key));
    });
    return lvl_list;
};

/**
 * 获取累计登陆天数列表
 * @return {[type]}     [description]
 */
exports.getSevenLoginLevelList = function () {
    var day_list = [];
    dataApi.seven_day.each(function (sprint_day_item, key) {
        day_list.push(parseInt(key));
    });
    return day_list;
};

/**
 * 获取冲级等级列表
 * @return {[type]}     [description]
 */
exports.getLevelList = function () {
    var lvl_list = [];
    dataApi.sprint_num.each(function (sprint_num_item) {
        lvl_list.push(sprint_num_item.id);
    });
    return lvl_list;
};

/**
 * 获取等级对应奖励排名
 * @param  {[type]} vip [description]
 * @return {[type]}     [description]
 */
exports.getRankNumBylevel = function (lv) {
    var sprint_num_conf = dataApi.sprint_num.findById(lv);
    return sprint_num_conf.num;
};

/**
 * 获取冲级奖励
 * @param  {[type]} vip [description]
 * @return {[type]}     [description]
 */
exports.getRewardListBylevel = function (lv) {
    var rewarad_conf = dataApi.sprint_lvl.findById(lv);
    return rewarad_conf;
};

/**
 * 获取累计登陆奖励
 * @param  {[type]} vip [description]
 * @return {[type]}     [description]
 */
exports.getSevenLoginRewardList = function (day, first_week) {
    if (!!first_week) {
        return dataApi.first_seven_day.findById(day);
    } else {
        return dataApi.seven_day.findById(day);
    }
};

/**
 * 获取成长基金奖励信息
 */
exports.getGrowFundRewardList = function (level) {
    return dataApi.grow_fund.findById(level);
};
